#include "referee.h"
#include "referee_ui.h"
#include "rtdef.h"
#include "rtthread.h"
#include "rttypes.h"

#define LOG_TAG              "referee_task"
#define LOG_LVL              LOG_LVL_DBG
#include <ulog.h>

/* 串口设备句柄 */
extern rt_device_t referee_serial;
/* 指向信号量的指针 */
extern rt_sem_t referee_sem;

rt_uint8_t buff[BSP_UART6_RX_BUFSIZE]={0};
void referee_thread_entry(void *parameter){

    while (1) {
        if (rt_sem_take(referee_sem,RT_WAITING_FOREVER)==RT_EOK)
        {
            //rt_device_read(referee_serial,0,buff,BSP_UART6_RX_BUFSIZE);
            LOG_D("referee_read\n");
        }
        rt_thread_mdelay(1000);
    }
    
}

int referee_task_init(void){
    rt_err_t ret = RT_EOK;
    /* 创建 serial 线程 */
    rt_thread_t thread = rt_thread_create("referee", referee_thread_entry, RT_NULL, 2048, 22, 10);
    /* 创建成功则启动线程 */
    if (thread != RT_NULL)
    {
        rt_thread_startup(thread);
    }
    else
    {
        ret = RT_ERROR;
    }

    LOG_D("referee thread init success!\n");

}

//INIT_APP_EXPORT(referee_task_init);